/*******************************************************************************
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *  
 * Copyright (c) 2011 Michael Chan.
 ******************************************************************************/
package com.google.code.solrdimension.config.converters;

import java.util.List;

import com.google.code.solrdimension.config.dimensionvalue.AbstractDimensionValueConfig;
import com.google.code.solrdimension.parsers.beans.Dimension;
import com.google.code.solrdimension.parsers.beans.DimensionValue;

/**
 * The AbstractDimensionConfigConverter provides common operations necessary for converting an
 * {@link DimensionValueConfig} to {@link AbstractDimensionValueConfig}
 * 
 * @author mhc
 *
 */
public abstract class AbstractDimensionConfigConverter implements DimensionValueConverter {


    /**
     * Setting common fields in dimensionValueConfig inherited from AbstractDimensionValueConfig
     * 
     * @param dimensionValueConfig
     *            An instance of subclass of {@link AbstractDimensionValueConfig}
     * @param dimensionValue
     *            An instance of subclass of {@link DimensionValue}
     * @param dimension
     *            The dimension encapsulating the dimensionvalues
     */
    public void setCommonFields(AbstractDimensionValueConfig dimensionValueConfig, DimensionValue dimensionValue, Dimension dimension){
        
        if (dimensionValueConfig != null && dimensionValue != null && dimension != null){
            
            dimensionValueConfig.setDimensionId(dimension.getId());
            dimensionValueConfig.setDisplayName(dimensionValue.getName());
            dimensionValueConfig.setDimensionValueId(dimension.getId() + dimensionValue.getId());
            dimensionValueConfig.setOrder(dimensionValue.getOrder());
            
        } else {
            //TODO - consider throwing some sort of exception
        }
        
    }
}
